    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <body>
        <script type="text/javascript">
            // var xhr;
            // if(window.XMLHttpRequest){
            //     xhr = new XMLHttpRequest();
            // }else{
            //     xhr = new ActiveXObject('Microsoft.XMLHTTP');
            // }
            // console.log(xhr.readyState);
            // xhr.open('GET', 'https://jsonplaceholder.typicode.com/todos', true);
            // xhr.send();
            // console.log(xhr.readyState);

            // xhr.onreadystatechange = function(){
            // console.log(xhr.readyState);

            //     if(xhr.readyState === 4 && xhr.status === 200){
            //         // console.log(xhr.responseText);
            //     }
            // }


            var xhr;
            if(window.XMLHttpRequest){
                xhr = new XMLHttpRequest();
            }else{
                xhr = new ActiveXObject('Microsoft.XMLHTTP');
            }
            console.log(xhr.readyState);
            xhr.open('POST', 'https://jsonplaceholder.typicode.com/todos', true);
            xhr.setRequestHeader('Content-type', 'application/json; charset=UTF-8')
            xhr.send(JSON.stringify({
            title: 'foo1',
            body: 'ba1r',
            userId: 100
            }));
            console.log(xhr.readyState);

            xhr.onreadystatechange = function(){
            console.log(xhr.readyState);
            console.log(xhr.status); //在HTTP协议中，201 Created 是一个代表成功的应答状态码，表示请求已经被成功处理，并且创建了新的资源。新的资源在应答返回之前已经被创建。同时新增的资源会在应答消息体中返回，其地址或者是原始请求的路径，或者是 Location 首部的值。

                if(xhr.readyState === 4 && xhr.status === 200){
                    console.log(xhr.responseText);
                }
            }
        </script>
    </body>
    </html>